//int sum(int a, int b) {
//  return a + b;
//}

// preceding method definition can be rewritten as:
def sum(a, b) {
  a + b
}

//// calling method ////
sum(1,2)

sum 1, 2

//// default value of param ////
def divide(number, by=2) {
  number/by
}

println divide (10, 5)
println divide (10)


//// map as param ////
def method(Map options) {
  def a = options.a ?: 10
  def b = options.b ?: 20
  // ... something meaningful here
}

method([a:10,b:20])
method(a:10, b:20)
method b:30, a:40
method b:30

//// varargs ////
def sumSquares(...numbers) {
  numbers.collect{ it * it }.sum()
}
sumSquares 1, 2, 3

//// closure as param ////
def myMethod (param, cls) {
  //... do something with params
}

myMethod(1, { /*...*/ })
myMethod 2, { /*...*/ }
myMethod(3) { /*...*/ }
